package com.example.mall.client.fallback;

import com.example.mall.client.SearchFeignClient;
import com.example.mall.doc.ProductsDoc;
import com.example.mall.query.ProductsQueryDto;
import com.example.mall.result.JSONResult;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * @Author: xxxliu
 * @CreateTime: 2025-06-06
 * @Version: 1.0
 */
@Component
public class SearchFeignClientFactory implements FallbackFactory<SearchFeignClient> {
    @Override
    public SearchFeignClient create(Throwable throwable) {
        return new SearchFeignClient() {
            @Override
            public JSONResult addProduct(ProductsDoc doc) {
                return JSONResult.error("商品新增失败");
            }

            @Override
            public JSONResult batchAddProduct(ProductsDoc[] docs) {
                return JSONResult.error("商品批量新增失败");
            }

            @Override
            public JSONResult getById(Long id) {
                return JSONResult.error("商品根据id查询失败");
            }

            @Override
            public JSONResult deleteById(Long id) {
                return JSONResult.error("商品删除失败");
            }

            @Override
            public JSONResult deleteProduct(ProductsDoc doc) {
                return JSONResult.error("商品批量删除失败");
            }

            @Override
            public JSONResult searchProduct(ProductsQueryDto dto) {
                return JSONResult.error("商品查询失败");
            }
        };
    }
}
